package com.myapp.myhome.fragment;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;

import com.myapp.myhome.activity.CheckoutActivity;
import com.myapp.myhome.activity.SearchAllInfoActivity;
import com.myapp.myhome.activity.SearchPerInfoActivity;
import com.myapp.myhome.activity.SubmitInfoActivity;
import com.myapp.myhome.R;

public class Fragment_Home extends Fragment implements OnClickListener {

    private View cView;
    private TextView title_text;
    private Button menu_btn_1;// 进入记账界面
    private Button menu_btn_2;// 进入查询界面
    private Button menu_btn_3;// 进入分类查询界面
    private Button menu_btn_4;// 进入结算中心，进行结算

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        if (cView == null) {
            cView = inflater.inflate(R.layout.fragment_layout_home, container,
                    false);
        }
        init();
        return cView;

    }

    private void init() {
        title_text = (TextView) cView.findViewById(R.id.titlebar_title);
        title_text.setText("302理财");

        // 第一个按钮
        menu_btn_1 = (Button) cView.findViewById(R.id.home_menu_item_btn_1);
        menu_btn_2 = (Button) cView.findViewById(R.id.home_menu_item_btn_2);
        menu_btn_3 = (Button) cView.findViewById(R.id.home_menu_item_btn_3);
        menu_btn_4 = (Button) cView.findViewById(R.id.home_menu_item_btn_2_1);
        menu_btn_1.setOnClickListener(this);
        menu_btn_2.setOnClickListener(this);
        menu_btn_3.setOnClickListener(this);
        menu_btn_4.setOnClickListener(this);

    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.home_menu_item_btn_1:
                Intent it_sub = new Intent(getActivity(), SubmitInfoActivity.class);
                startActivity(it_sub);
                break;
            case R.id.home_menu_item_btn_2:
                Intent it_search = new Intent(getActivity(),
                        SearchAllInfoActivity.class);
                startActivity(it_search);
                break;
            case R.id.home_menu_item_btn_3:
                Intent it_perinfo = new Intent(getActivity(),
                        SearchPerInfoActivity.class);
                startActivity(it_perinfo);
                break;
            case R.id.home_menu_item_btn_2_1:
                Intent it_checkout = new Intent(getActivity(),
                        CheckoutActivity.class);
                startActivity(it_checkout);
                break;
        }
    }

}
